package com.sinosoft.demo2;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MySQLDemo {
    public static void main(String[] args) throws ClassNotFoundException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://10.146.36.4:3306/6icustomer?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai";
        String username = "6icustomer";
        String password = "Sgec4#Dh";

        try {
            Connection connection = DriverManager.getConnection(url, username, password);
            System.out.println("成功建立数据库连接");
            // 执行SQL查询和处理结果的代码在这里
            connection.close(); // 关闭数据库连接
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("建立数据库连接失败：" + e.getMessage());
        }
    }
}
